package com.cloud.system.api.mapper;

import com.cloud.system.api.entity.PowerBasis;
import com.cloud.system.common.utils.BaseMapperHelper;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PowerBasisMapper extends BaseMapperHelper<PowerBasis> {

    @Select("select power_id, cause_id, set_basis_code, infringe_basis, punish_basis, set_basis from power_basis where power_id = #{powerId}")
    @Results({
            @Result(property = "powerId",column = "power_id",javaType = Integer.class),
            @Result(property = "causeId", column = "cause_id", javaType = Long.class),
            @Result(property = "setBasisCode", column = "set_basis_code", javaType = String.class),
            @Result(property = "infringeBasis", column = "infringe_basis", javaType = String.class),
            @Result(property = "punishBasis", column = "punish_basis", javaType = String.class),
            @Result(property = "setBasis", column = "set_basis", javaType = String.class),
    })
    List<PowerBasis> getPowerBasisByPowerId(Integer powerId);

//    @Select("insert into power_basis(power_id,cause_id,set_basis_code,infringe_basis,punish_basis,set_basis) value(#{powerId},#{causeId},#{setBasisCode},#{infringeBasis},#{punishBasis},#{setBasis})")
//    void saveUpdatePowerBasis(@Param("powerId")Integer powerId, @Param("causeId")Long causeId, @Param("setBasisCode")String setBasisCode,
//                              @Param("infringeBasis")String infringeBasis, @Param("punishBasis")String punishBasis, @Param("setBasis")String setBasis);

//    @Select("delete from power_basis where power_id = #{powerId} and basis_type = #{basisType} and basis_code = #{basisCode}")
//    void deletePowerBasisById(@Param("powerId")Integer powerId, @Param("basisType")Long basisType, @Param("basisCode")String basisCode);

    @Delete("delete from power_basis where power_id = #{powerId}")
    @ResultType(Integer.class)
    int deletePowerById(Integer powerId);

}
